require('./Listitem.styl');
import { Boxs } from 'saltui'
import People from 'images/svg/people.svg'
import Evaluate from 'images/svg/evaluate.svg'
import { Control } from 'react-keeper'
const { HBox, Box, VBox } = Boxs;
const component = {
    "teacher":People,
    "parent":Evaluate
}
class Listitem extends React.Component {

    constructor(props) {
        super(props);
        this.state = {
        };
        this.handleClick = this.handleClick.bind(this);
    }
    handleClick() {
        if (this.props.refreshing) return;
        if (this.props.type == "teacher") {
            let { schoolId, evaluateId, isCanEdit } = this.props.data;
            Control.go('/home/evaluatedetail', { data: { schoolId, evaluateId, isCanEdit } })
        } else if (this.props.type == "parent") {
            let { schoolId, evaluateId } = this.props.data;
            Control.go('/parentEvaluate/evaluatedetail', { data: { schoolId, evaluateId } })
        }
    }
    render() {
        var Component = component[this.props.type];
        return (
            <div className="teacher-listitem parent-listitem" onClick={this.handleClick}>
                <VBox>
                    <HBox vAlign="center">
                        <Box>
                            <Component fill="rgb(217,229,241)" width="20" height="20" />
                        </Box>
                        <Box flex={2} className="t-ML14 omt">
                            {this.props.data.title}
                        </Box>
                        <Box flex={1} className="t-FAR teacher-listitem-date parent-listitem-date">
                            {this.props.data.subtitle}
                        </Box>
                    </HBox>
                    <HBox className="t-MT6 omt teacher-listitem-content parent-listitem-content">
                        <Box>{this.props.data.content}</Box>
                    </HBox>
                </VBox>
            </div>
        );
    }

    componentWillMount() {
    }

    componentDidMount() {
    }

    componentWillReceiveProps(nextProps) {
    }

    shouldComponentUpdate(nextProps, nextState) {
        return true;
    }

    componentWillUpdate(nextProps, nextState) {
    }

    componentDidUpdate(prevProps, prevState) {
    }

    componentWillUnmount() {
    }
}

module.exports = Listitem;
